﻿<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>菜单-新增</title>

    <link rel="shortcut icon" href="favicon.ico">
	<link href="css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
	<link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="css/style.min.css?v=4.0.0" rel="stylesheet">
	<style>
		.control-label{
			line-height:35px;
			text-align:center;
		}

		.ibox-content{
			padding:0 0 20px 0;
		}
	</style>
</head>

<body class="gray-bg">
    <div class="wrapper animated fadeInRight">

        <div class="row">
			<div class="ibox-content">
				<form id="argForm" class="form-horizontal m-t">

					<div class="form-group">
						<input name="id" type="hidden" value="" />
						<label class="col-xs-3 control-label">父级菜单：</label>
						<div class="col-xs-8">
							<select id="pCode" class="form-control" name="pCode">
							</select>
						</div>
                    </div>
					<div class="form-group">
						<label class="col-xs-3 control-label">菜单名称：</label>
						<div class="col-xs-8">
							<input id="mName" name="mName" class="form-control" type="text">
							<!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-3 control-label">菜单代码：</label>
						<div class="col-xs-8">
							<input id="mCode" name="mCode" class="form-control" type="text">
							<!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-3 control-label">状态：</label>
						<div class="col-xs-8">
							<div class="radio i-checks">
								<label>
									<input id="status_on" type="radio" checked="" value="ON" name="status"> <i></i>启用</label>

								<label>
									<input id="status_off" type="radio" value="OFF" name="status"> <i></i>禁用</label>
							</div>
						</div>
					</div>
					<div class="form-group">
						<input name="id" type="hidden" value="" />
						<label class="col-xs-3 control-label">配置路径：</label>
						<div class="col-xs-8">
							<input id="mUrl" name="mUrl" class="form-control" type="text">
							<!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-3 control-label">Icon：</label>
						<div class="col-xs-8">
							<input id="mIcon" name="mIcon" class="form-control" type="text">
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-3 control-label">排序：</label>
						<div class="col-xs-8">
							<input id="sort" name="sort" class="form-control" type="text">
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-3 control-label">备注：</label>
						<div class="col-xs-8">
							<input id="note" name="note" class="form-control" type="text">
						</div>
					</div>
					<div class="form-group">
						<div class="col-xs-3 col-xs-offset-8">
							<button class="btn btn-primary" onclick="AddSysMenu();" type="button">提交</button>
						</div>
					</div>
				</form>
			</div>
        </div>
    </div>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.5"></script>
    <script src="js/content.min.js?v=1.0.0"></script>
	<script src="js/plugins/toastr/toastr.min.js"></script>
    <script src="js/plugins/validate/jquery.validate.min.js"></script>
    <script src="js/plugins/validate/messages_zh.min.js"></script>
    <script src="js/plugins/iCheck/icheck.min.js"></script>
	<script src="js/custom/layTool.js"></script>
    <script type="text/javascript" src="js/custom/app.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/custom/tools.js" charset="UTF-8"></script>
	<script>
        $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
    </script>

	<script>
		//获取一二级菜单
	$(function(){
		//初始用户信息（全局）
		var url = 'sysMenu/getOneTwoCascadeSysMenuList';
		jQuery.ajax({
			url:domain + url,
			type:"get",
			data:{},
			crossDomain:true,
			async: false,
			xhrFields:{
				withCredentials:true
			},
			success:function (data) {
				if(data.status == 200){
					combOneTwoCascadeSysMenu(data.data);
				}else{
					top.toastr.warning(data.msg);
				}
			},
			error:function(data) {
				top.toastr.error("查询列表失败，请检查网络");
			}
		})
	})

	function combOneTwoCascadeSysMenu(data){
		var htmls = new Array();
		for (var i=0;i<data.length;i++){
			var sysMenu1 = data[i].sysMenu;
			var sysMenu1List = data[i].sysMenuList;

			htmls.push('<option value="'+ sysMenu1.mCode +'">'+ sysMenu1.mName +'</option>');

			for(var j=0;j<sysMenu1List.length;j++){
				var sysMenu2 = sysMenu1List[j].sysMenu;
				var sysMenu2List = sysMenu1List[j].sysMenuList;

				htmls.push('<option value="'+ sysMenu2.mCode +'">&nbsp;&nbsp;&nbsp;├&nbsp;'+ sysMenu2.mName +'</option>');

				for(var k=0;k<sysMenu2List.length;k++){
					var sysMenu3 = sysMenu2List[k].sysMenu;

					htmls.push('<option value="'+ sysMenu3.mCode +'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├&nbsp;'+ sysMenu3.mName +'</option>');

				}
			}

		}
		$("select[name=pCode]").html(htmls.join(''));

	}


		function AddSysMenu(){

			var formData = new FormData($("form#argForm")[0]);
			var url = 'sysMenu/addSysMenu';
			jQuery.ajax({
				url:domain + url,
				type:"post",
				data:JSON.stringify(formData2JsonStr(formData)),
				contentType:"application/json;charset=utf-8",
				crossDomain:true,
				xhrFields:{
					withCredentials:true
				},
				success:function (data) {
					if(data.status == 200){
						callFn("getAllSysMenuList");
					}else{
						top.toastr.warning(data.msg);
					}
				},
				error:function(data) {
					top.toastr.error("操作失败，请检查网络");
				}
			})
		}


	</script>

</body>

</html>
